package com.gc.server.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yf.annotation.SysLog;
import java.util.Map;
import com.yf.consts.DaoConst;
import com.gc.server.entity.ActRecordEntity;
import com.gc.server.service.ActRecordService;
import com.yf.response.R;


/**
 * 活动记录Controller
 *
 * @author hxf
 * @email 505860922@qq.com
 * @date Tue Mar 10 11:17:44 CST 2020
 */
@RestController
@RequestMapping("/act/record")
public class ActRecordController {
    @Autowired
    private ActRecordService actRecordService;

    /**
     * 列表活动记录
     */
    @RequestMapping("/list")
    @RequiresPermissions("act:record:list")
    public R list(@RequestParam Map<String,Object> params) {
        PageHelper.startPage(DaoConst.getPage(params),DaoConst.getLIMIT(params));
        List<ActRecordEntity> actRecordList = actRecordService.queryList(params);
        return R.ok(new PageInfo(actRecordList));
    }

    /**
     * 查看活动记录
     */
    @SysLog("查看活动记录")
    @RequestMapping("/info/{id}")
    @RequiresPermissions("act:record:info")
    public R info(@PathVariable("id") Long id) {
        ActRecordEntity actRecord = actRecordService.get(id);

        return R.ok(actRecord);
    }

    /**
     * 保存活动记录
     */
    @SysLog("保存活动记录")
    @RequestMapping("/save")
    @RequiresPermissions("act:record:save")
    public R save(ActRecordEntity actRecord) {
        actRecordService.save(actRecord);

        return R.ok(actRecord);
    }

    /**
     * 修改活动记录
     */
    @SysLog("修改活动记录")
    @RequestMapping("/update")
    @RequiresPermissions("act:record:update")
    public R update(ActRecordEntity actRecord) {
        actRecordService.update(actRecord);

        return R.ok(actRecord);
    }

    /**
     * 删除活动记录
     */
    @SysLog("删除活动记录")
    @RequestMapping("/delete")
    @RequiresPermissions("act:record:delete")
    public R delete(Long[]ids) {
        actRecordService.deleteBatch(ids);

        return R.ok();
    }

    /**
     * 所有活动记录
     */
    @SysLog("所有活动记录")
    @RequestMapping("/queryAll")
    public R queryAll (@RequestParam Map<String,Object> params) {

        List<ActRecordEntity> actRecordList = actRecordService.queryList(params);

        return R.ok(actRecordList);
    }

    /**
    @ModelAttribute
    public SearchParam<ActRecordEntity> searchParam(SearchParam<ActRecordEntity> params, ActRecordEntity actRecord) {
        if (actRecord != null) {
            params.setEntity(actRecord);
        }

        return params;
    }
 **/
    /***********自定义开始***********/
}
